"""
生成器 - 迭代器语法简化升级版
生成器表达式 ---> (num for num in range(1, 100, 2))
"""


def fib(num):
    a, b = 0, 1
    for _ in range(num):
        a, b = b, a + b
        yield a


# 调用函数不是简单的获得返回值，而是创建了生成器对象
fib_iter = fib(20)
print(type(fib_iter))
# print(next(fib_iter))
for value in fib_iter:
    print(value)

num_gen = (num for num in range(1, 100, 2))
print(type(num_gen))


def create_num_gen():
    yield from range(1, 100, 2)
